package nina.yiyou.performance.s11collect.input

import groovy.transform.PackageScope
import nina.yiyou.salary.input.util.CellValueGetter
import org.apache.poi.ss.usermodel.Row

@PackageScope
class GroupColumnGetter {

  GroupColumnGetter(List<Row> dataRows) {
    _dataRows = dataRows
  }

  Map getColumn() {
    Map<Integer, String> result = [:]
    String groupCursor = null

    for (int i = 0; i < _dataRows.size(); i++) {
      groupCursor = new CellValueGetter(_dataRows[i].getCell(0)).get() ?: groupCursor
      result[i] = groupCursor
    }
    return result
  }

  private final List<Row> _dataRows
}
